package com.jpcc.vw.onlineRadio.adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.jpcc.vw.onlineRadio.adapter.item.CommonFavouritePaiedHistoryItem;
import com.jpcc.vw.onlineRadio.model.bean.CommonFavouritePaiedHistoryEntity;
import com.jpcc.vw.onlineRadio.recycle.RecyclerView.BaseItem;
import com.jpcc.vw.onlineRadio.recycle.RecyclerView.MultiTypeListAdapter;

import java.util.ArrayList;
import java.util.List;

public class CommonFavouritePaiedHistoryAdapter extends MultiTypeListAdapter<CommonFavouritePaiedHistoryEntity> {


    private List<CommonFavouritePaiedHistoryEntity> datas = new ArrayList<>();
    private Context context;

    public CommonFavouritePaiedHistoryAdapter(List<CommonFavouritePaiedHistoryEntity> datas, Context context) {
        if (datas != null) {
            this.datas.clear();
            this.datas.addAll(datas);
        }
        this.context = context;
    }

    @Override
    public CommonFavouritePaiedHistoryEntity getItem(int viewType, int position) {
        return datas.get(position);
    }

    @Override
    public BaseItem<CommonFavouritePaiedHistoryEntity> createItemView(ViewGroup parent, int viewType) {
        return new CommonFavouritePaiedHistoryItem(parent);
    }

    @Override
    public int getItemCount() {
        return this.datas.size();
    }

    public void setDatas(List<CommonFavouritePaiedHistoryEntity> data){
        if (data != null) {
            this.datas.clear();
            this.datas.addAll(data);
            notifyDataSetChanged();
        }
    }

    public List<CommonFavouritePaiedHistoryEntity> getDatas(){
        if(this.datas!=null){
            return this.datas;
        }
        return new ArrayList<>();
    }
}
